﻿using BotDetector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace example
{
    class BotDetectorA
    {
        private String search;
        private String key;
        public BotDetectorA(String search, String key)
        {
            this.search = search;
            this.key = key;
            
        }
        public Boolean Analyze()
        {
            var bing = new Bing.BingSearchContainer(
                new Uri("https://api.datamarket.azure.com/Bing/Search/")) { Credentials = new System.Net.NetworkCredential(key, key) };
            var query = bing.Web(search, null, null, null, null, null, null, null);
           // query = query.AddQueryOption("$top", 10);
            var results = query.Execute();
            int i = 0;

            foreach (var result in results)
            {
                i++;
                Console.WriteLine(result.Url);
            }
            Console.WriteLine(i);

            if (search.Length < 10 && i < 30 || search.Length < 20 && i < 20 || search.Length > 20 && i < 10)
                return false;
            else
                return true;
        }
    }
}
